﻿/* 
 * \brief Manages all player entities within the game
 * Can create player objects within the world
 */

using System;
using UnityEngine;

using KaoticSSB.Weapons;

namespace KaoticSSB.Players
{
	public class WeaponManager : MonoBehaviour
	{
		public Rigidbody2D ThrowingWeaponBase;
		public Transform MeleeWeaponBase;

		public WeaponManager ()
		{
		}
		
		public Rigidbody2D CreateThrowingWeapon(PlayerBase player)
		{
			if(player != null)
			{
				Vector3 spawnLocation = player.transform.position;
				Rigidbody2D gameObj = Instantiate(ThrowingWeaponBase, spawnLocation, Quaternion.identity) as Rigidbody2D;
				ThrowingWeapon weapon = gameObj.GetComponent<ThrowingWeapon>();
				weapon.PlayerID = player.PlayerIndex;
				return gameObj;
			}
			return null;
		}

		public Transform CreateMeleeWeapon(PlayerBase player)
		{
			if(player != null)
			{
				Vector3 spawnLocation = player.transform.position;
				Transform gameObj = Instantiate (MeleeWeaponBase, spawnLocation, Quaternion.identity) as Transform;
				MeleeWeapon weapon = gameObj.GetComponent<MeleeWeapon>();
				weapon.PlayerID = player.PlayerIndex;
				return gameObj;
			}
			return null;
		}
	}
}

